
//
//  AchiveTool.m
//  GTQCitySelector
//
//  Created by 光头强 on 16/7/21.
//  Copyright © 2016年 Ls. All rights reserved.
//

#import "AchiveTool.h"

@implementation AchiveTool
//Documents
+ (void)achiveWithArray:(NSMutableArray *)array FileName:(NSString *)fileName
{
    NSString *filePath = @"Documents/";
    NSString *localPath = [filePath stringByAppendingString:fileName] ;
    
    NSString * path = [NSHomeDirectory() stringByAppendingPathComponent:localPath];
    
    BOOL flag = [NSKeyedArchiver archiveRootObject:array toFile:path];
    
    if (flag) {
        
        NSLog(@"归档成功");
    }
    
    else
    {
        NSLog(@"归档失败");
    }
}

+ (NSMutableArray *)unAchiveWithFileName:(NSString *)fileName
{
    NSString *filePath = @"Documents/";
    NSString *localPath = [filePath stringByAppendingString:fileName] ;
    
    NSString * pathMuArrayFindHistory = [NSHomeDirectory() stringByAppendingPathComponent:localPath];
    NSMutableArray *arr = [NSKeyedUnarchiver unarchiveObjectWithFile:pathMuArrayFindHistory];
    
    return arr;
}
@end
